1 Week One

1.1 Temperature Overtime

I worked on familiarizing myself with the show your stripes website, climate tracking, NOAA, the berkeley earth project, and all things related to climate data that I didn’t know about. I also learned the SF package, github desktop and using github from R. Lastly, I learned about shapefiles, using ArcGIS, extracting and plotting shapefiles.

1.1.1 Guiding questions

  • Can we access them readily, and how (download, api, etc.)? If it can be called directly from the source into R (or Python), that’s our preferred approach.

  • What’s the smallest spatial scale available? What format are they in (csv, json, excel, etc; or for spatial data, raster or vector)? What time period/years are present?

  • Could we use them to measure what we think we can? What attributes/variables are available? How have they been used in related work?

  • How are they generated, where do they come from (e.g., processed from instruments/satellite, derived from surveys, modeled from multiple sources, etc.)?

  • key regions (FIPS): The larger Charlottesville area: Charlottesville City (51540), Albemarle County (51003), Fluvanna (51065), Greene (51079), Louisa (51109), Nelson (51125) The Eastern Shore area: Accomack (51001), Northhampton (51131)

1.2 Show your Stripes and Berkeley Earth

  • The image is only available for state data and the raw data is not available through the site. We can download the completed graphics and use another source (https://creativecommons.org/use-remix/) to build on the graphics and reuse them if necessary.

  • Berkeley earth also only has state level sources. We can download a txt file for virginia as a whole but not county level data.

1.3 ArcGIS

  • The images are available for county data but the raw data is not available through the site. I downloaded the completed graphics for the key regions.

    • Charlottesville City (51540)

    • Albemarle County (51003)

    • Fluvanna (51065)

    • Greene (51079)

    • Louisa (51109)

    • Nelson (51125)

    • Accomack (51001)

    • Northhampton (51131)

1.4 Forecast Scenarios

The UCAR Climate Change Forecast Scenarios page (https://gisclimatechange.ucar.edu/gis-climatedata) allows downloads of data for a particular county as long as you can draw the location on the map using the box tool. It can forecast from 2006 up to year 2100 but it is only possible to download up to 10 years as shapefiles for each scenario. However, it is possible can download the full forecast as txt files. Please let me know if you would like me to download the data for the key regions and for what date ranges and scenarios. For shapefiles, I can download a 100 year forecast in 10 downloads if that is preferred to txt files.

I found two other forecast tools but they are not as good as the UCAR website.

  • The CREAT CLimate Scenarios Projection Map (https://www.arcgis.com/apps/MapSeries/index.html?appid=3805293158d54846a29f750d63c6890e) can show forecasts for year 2035 and 2060 for temperature, percipitation, storms, extreme heat, and sea levels. It is possible to get county forecast by zooming into the map and clicking on the county of interest. However, it is not possible to download the data.

  • The NOAA CM2.X dataset contains the results of two models run by the NOAA’s Geophysical Fluid Dynamics Laboratory (GFDL). They show general climate conditions during the 20th century and projections into the 21st century based on various climate scenarios. It can be downloaded at (https://www.ncdc.noaa.gov/data-access/model-data/model-datasets/cm2-global-coupled-climate-models-cm2x). While it does not show the map of the forecasts, we can download the data and create our own. This is also a global forecast so chances of extracting county level data might be slim. It covers January 1, 1901 to April 21, 2300.

1.5 NOAA Data

NOAA has data that covers county, regional, state, country, and global levels. NOAA data is extractable in txt format and through API for date ranges 1895-2021.

  • Monthly readings for each county measuring
    • 01 = Precipitation
    • 02 = Average Temperature
    • 27 = Maximum Temperature
    • 28 = Minimum Temperature
  • The data is used to calculate the state temperature which is then used in regional and country-wide calculations. Minimum and Maximum would be useful if we wanted to run our own calculations but the average temperature is usually a standard measurement of temperature overtime.

The nClimDiv dataset contains the county information that we are looking to access from NOAA. The dataset is derived from the station information in the daily Global Historical Climatology Network (GHCN) dataset. Therefore, the nClimDiv is the processed data format of the GHCN and would be more useful to us than getting raw GHCN data.

My NOAA script so far is:

# 0. Load libraries and data
library(tidyverse)
library(stargazer) # for summary table
library(janitor) # for tabyl
library(tigris) # for shapefiles
library(sf) # for spatial joins
library(leaflet) # for map
library(viridis)
library(googlesheets4)
library(RColorBrewer)
library(ggplot2)
library(gganimate)
library(gapminder)
library(transformr)
library(gifski)
library(ggrepel)
library(hrbrthemes)
library(devtools)
library(climatestripes)
library(lubridate)
library(ggExtra)
library(tidyr)
library(dygraphs)
library(xts)
library(lubridate)
library(zoo)
library(tidyselect)

This was to load the average temperature data

climcounty <- read.table(file = "climdiv-tmpccy-v1.0.0-20210604.txt", header = FALSE)
head(climcounty)
##           V1   V2
## 1 1001021895 44.0
## 2 1001021896 44.3
## 3 1001021897 43.7
## 4 1001021898 50.1
## 5 1001021899 44.6
## 6 1001021900 43.9
##     V3   V4   V5
## 1 38.2 55.5 64.1
## 2 49.0 54.0 69.3
## 3 52.3 61.3 63.0
## 4 46.8 60.1 59.6
## 5 41.5 56.6 62.3
## 6 45.1 53.8 65.3
##     V6   V7   V8
## 1 70.6 78.3 80.4
## 2 76.8 78.0 81.7
## 3 70.0 82.4 82.4
## 4 75.0 81.5 80.8
## 5 76.7 81.0 81.0
## 6 71.7 76.4 80.6
##     V9  V10  V11
## 1 80.4 79.0 61.4
## 2 83.1 77.9 64.7
## 3 79.6 76.6 67.4
## 4 79.2 76.2 62.1
## 5 81.5 74.3 66.6
## 6 81.5 78.1 69.3
##    V12  V13
## 1 54.4 45.3
## 2 58.0 47.3
## 3 54.9 48.2
## 4 50.2 44.2
## 5 55.7 45.3
## 6 56.1 48.3

This was to load the county data with shapefiles

ccshape <- st_read("/Users/msbugatti/Documents/GitHub/EQCSummer2021/counties")
## Reading layer `Counties' from data source 
##   `/Users/msbugatti/Documents/GitHub/EQCSummer2021/counties' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 3117 features and 48 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -178.2176 ymin: 18.92179 xmax: -66.97825 ymax: 71.40624
## Geodetic CRS:  WGS 84

This was to filter the county data to the counties of interest

ccshape1 <- ccshape %>% filter(FIPS %in% c(51540, 51003, 51065, 51079, 51109, 51125, 51001, 51131))

This was my first run at ploting the data. It is very bland.

ggplot() + 
  geom_sf(data = ccshape1, size = 3, color = "black", fill = "orange") + 
  ggtitle("Virginia Counties Plot") + 
  coord_sf()

1.5.1 Goals for this week

  • Get NOAA data, clean it, and explore the observations (distributions across spatial units, summaries by spatial units, etc.)

  • Learn lovelace and other ploting skills for shapefiles in R

  • Practice GitHub from terminal instead of GitHub desktop which is much more easy for me to use.

  • Lastly, a gif of my life this week

2 Week Two and Three

After spending most of week two figuring out the data mapping. I worked on the animated map this week and spent more time trying to figure out why my map was displaying two labels for one frame during the animation process. I finally got it to work last night but am now dealing with a .nc read problem with the DAYMET dataset. This should be faster once I can read it into R. I am excited to work on the strips and yearly average data for the NOAA dataset.

2.1 My codes and the animated map for july are below.

climcounty <- rename(climcounty, Fipsyear=V1, Jan=V2, Feb=V3, Mar=V4, Apr=V5, May=V6, Jun=V7, Jul=V8, Aug=V9, Sep=V10, Oct=V11, Nov=V12, Dec=V13)
countyavgtemp <- climcounty %>% filter(Fipsyear %in% c(44540021895:44540022021, 44003021895:44003022021, 44065021895:44065022021, 44079021895:44079022021, 44109021895:44109022021, 44125021895:44125022021, 44001021895:44001022021, 44131021895:44131022021))
countyavgtemp1 <- countyavgtemp %>%
  group_by(Fipsyear) %>% mutate(year = as.numeric(str_sub(Fipsyear, 8, )), CNTY_FIPS = str_sub(Fipsyear, 3, -7))
countyavgtemp1 <- countyavgtemp1 %>%
                      dplyr::select(CNTY_FIPS, year, Jan, Feb,
                                Mar, Apr, May, Jun, Jul, Aug, Sep,
                                Oct, Nov, Dec, Fipsyear)
ccshapegf <- left_join(ccshape1, countyavgtemp1, by ="CNTY_FIPS")
countyavgsf <- st_as_sf(ccshapegf)
ccshapegf <- cbind(ccshapegf, st_coordinates(st_centroid(ccshapegf)))
## Warning in
## st_centroid.sf(ccshapegf):
## st_centroid assumes
## attributes are
## constant over
## geometries of x
ccshapeggf <- 
  ggplot(ccshapegf) +
  geom_sf(aes(fill = Jul), color = "black", alpha = .9) +
   geom_text_repel(data = ccshapegf, aes(X, Y, label = NAME), size = 4, nudge_x = 1, nudge_y = 0, fontface = "bold", hjust = 0.9) +
  scale_fill_fermenter(palette = "YlOrRd", direction = 1,   type = "seq", n.breaks = 8) +
     theme_void() +
  guides(fill =
           guide_colourbar(title.position="top", title.hjust = 0.5,
                           barwidth = 1)
  )  + 
  labs(fill = "Temperature ", title = 'Year: {frame_time}',
       caption = "Average temperature in July for 7 Counties") + 
 transition_time(as.integer(year)) +
ease_aes('linear') 
animate(ccshapeggf, fps = 1, detail = 1, nframes = 127)

2.1.1 Goals for this Week

  • Finish the DAYMET data clean.

  • Work on the creating the stripes and a yearly average temperature data to create a new animation.

  • Create the rmd scripts, csv output data, and data review file for NOAA and DAYMET.

  • Work on the new goals for this week.

3 Week Four and Week Five

3.1 Charlottesvile Counties

noaa <- read_csv("noaa_cville_county.csv")
cvillefips <- c("540", "003", "065", "079", "109", "125")
meta <- read_sheet("https://docs.google.com/spreadsheets/d/1nqm3DuVXD1ObbVe_deacvT7uSLdBXfQJo3mkbqDwrVo/edit#gid=1573436636", sheet = "noaa")

3.2 Data Source

Source: NOAA’s Climate Divisional Database (nClimDiv), June 2021 release

3.2.1 The Data Used Here

The Climate Divisional Dataset from the National Center For Environmental Information began as the only long-term temporally and spatially complete dataset from which to generate historical climate analyses (1895-2013) for the contiguous United States (CONUS). It was originally developed for climate division, statewide, regional, national, and population-weighted monitoring of drought, temperature, precipitation, and heating/cooling degree day values.

There are 344 climate divisions in the CONUS. For each climate division, monthly station temperature and precipitation values are computed from the daily observations. The divisional values are weighted by area to compute statewide values and the statewide values are weighted by area to compute regional values. (Karl and Koss, 1984).

The data here is the county data from all the states in the contigous United States. While NOAA includes information on a variety of climate measures, we are focusing on the maximum, minimum temperature, and precipitation of the counties of interest.

To Learn More, See:

3.2.2 Variable Descriptions

glimpse(cville_sf1)
## Rows: 756
## Columns: 50
## $ NAME        <chr> …
## $ Year        <dbl> …
## $ CNTY_FIPS   <chr> …
## $ X           <dbl> …
## $ Y           <dbl> …
## $ STATE_FIPS  <chr> …
## $ FIPS        <chr> …
## $ AREA        <dbl> …
## $ Janmin      <dbl> …
## $ Febmin      <dbl> …
## $ Marmin      <dbl> …
## $ Aprmin      <dbl> …
## $ Maymin      <dbl> …
## $ Junmin      <dbl> …
## $ Julmin      <dbl> …
## $ Augmin      <dbl> …
## $ Sepmin      <dbl> …
## $ Octmin      <dbl> …
## $ Novmin      <dbl> …
## $ Decmin      <dbl> …
## $ Avg_Tempmin <dbl> …
## $ Janmax      <dbl> …
## $ Febmax      <dbl> …
## $ Marmax      <dbl> …
## $ Aprmax      <dbl> …
## $ Maymax      <dbl> …
## $ Junmax      <dbl> …
## $ Julmax      <dbl> …
## $ Augmax      <dbl> …
## $ Sepmax      <dbl> …
## $ Octmax      <dbl> …
## $ Novmax      <dbl> …
## $ Decmax      <dbl> …
## $ Avg_Tempmax <dbl> …
## $ Janpcp      <dbl> …
## $ Febpcp      <dbl> …
## $ Marpcp      <dbl> …
## $ Aprpcp      <dbl> …
## $ Maypcp      <dbl> …
## $ Junpcp      <dbl> …
## $ Julpcp      <dbl> …
## $ Augpcp      <dbl> …
## $ Seppcp      <dbl> …
## $ Octpcp      <dbl> …
## $ Novpcp      <dbl> …
## $ Decpcp      <dbl> …
## $ Tot_Temppcp <dbl> …
## $ Avg_Temppcp <dbl> …
## $ Fipsyear    <dbl> …
## $ geometry    <MULTIPOLYGON [°]> …

Observations are county level estimates of…

  • Monthly maximum temperature for each county for years 1895-2021
    • Yearly average maximum temperature for each county for those years.
  • Monthly minimum temperature for each county for years 1895-2021
    • Yearly average minimum temperature for each county for those years.
  • Monthly precipitation for each county for years 1895-2021
    • Total yearly precipitation for each county for those years.

3.2.3 Summaries

5-number summaries of (non-missing) numeric variables (remove non-numeric observations)

noaa %>% select(-c(CNTY_FIPS, Fipsyear, Year)) %>% 
  select(where(~is.numeric(.x) && !is.na(.x))) %>% 
  as.data.frame() %>% 
  stargazer(., type = "text", title = "Summary Statistics", digits = 0,
            summary.stat = c("mean", "sd", "min", "median", "max"))
## 
## Summary Statistics
## ========================================
## Statistic   Mean St. Dev. Min Median Max
## ----------------------------------------
## Janmin       24     4     11    24   37 
## Febmin       25     4     13    26   35 
## Marmin       33     4     20    33   43 
## Aprmin       42     2     34    42   50 
## Maymin       51     3     44   51.3  60 
## Junmin       60     2     53    60   66 
## Julmin       64     2     59    64   70 
## Augmin       63     2     57    63   68 
## Sepmin       56     3     49    56   65 
## Octmin       44     3     35    44   54 
## Novmin       34     3     27    34   44 
## Decmin       27     4     14    27   41 
## Avg_Tempmin  44     1     39    44   48 
## Janmax       44     5     29    44   58 
## Febmax       47     5     32    48   61 
## Marmax       56     5     41    56   70 
## Aprmax       67     3     56    67   75 
## Maymax       76     3     67    75   83 
## Junmax       83     3     73    83   89 
## Julmax       86     3     79    86   93 
## Augmax       84     3     75    84   94 
## Sepmax       78     3     70    78   88 
## Octmax       68     3     59    68   79 
## Novmax       57     4     47    57   66 
## Decmax       47     4     33    47   60 
## Avg_Tempmax  66     2     61    66   71 
## Janpcp       3      2      0    3     9 
## Febpcp       3      1      0    3     8 
## Marpcp       4      2      0    3     9 
## Aprpcp       3      2      0    3    12 
## Maypcp       4      2      0    4    11 
## Junpcp       4      2      1    4    13 
## Julpcp       4      2     -10   4    11 
## Augpcp       4      3     -10   4    14 
## Seppcp       4      3     -10   3    16 
## Octpcp       3      3     -10   3    13 
## Novpcp       3      2     -10   3    13 
## Decpcp       3      2     -10   3     8 
## Tot_Temppcp  43     11    -43   43   72 
## Avg_Temppcp  4      1     -4    4     6 
## ----------------------------------------

3.3 Maps, Warming Stripes, and Timeplots

3.3.1 July Temperatures

3.3.1.1 Maximum Temperature in July across Counties for all Years

cville_sf11a <- 
  ggplot(cville_sf1) +
  geom_sf(aes(fill = Julmax), color = "black", alpha = .9, na.rm = TRUE) +
   geom_text_repel(data = cville_sf1, aes(X, Y, label = NAME), size = 4, nudge_x = 1, nudge_y = 0, fontface = "bold", hjust = 0.9) +
  scale_fill_fermenter(palette = "YlOrRd", direction = 1,   type = "seq", n.breaks = 7) +
     theme_void() +
  guides(fill =
           guide_colourbar(title.position="top", title.hjust = 0.5,
                           barwidth = 1)
  )  + 
  labs(fill = "Temperature ", title = 'Year: {frame_time}',
       caption = "Maximum Temperature in July for Charlottesville Counties") + 
 transition_time(as.integer(Year)) +
ease_aes('linear') 
animate(cville_sf11a, fps = 1, detail = 1, nframes = 127)

meta %>%
  filter(varname == "Julmax") %>% 
  select(about) %>% 
  as.list()

$about [1] “Monthly Divisional Temperature format (f7.2) Range of values -50.00 to 140.00 degrees Fahrenheit. Decimals retain a position in the 7-character field. Missing values in the latest year are indicated by -99.99. Missing values removed for visualization, resulting in no plots for 2021”

3.3.1.2 Minimum Temperature in July across Counties for all Years

This is an interactive graph. Click on the graph to zoom, scroll through each year to see numeric temperature readings for all counties for each year.

cville_sf1a <- mutate(cville_sf1, date = str_c(Year, "07-16", sep = "-") %>% ymd())
cville_sf1p <- select(cville_sf1a, NAME, date, Julmin)
cville_sf1p <- as.data.frame(cville_sf1p)
cville_sf1p <- select(cville_sf1p, -starts_with("geometry"))
cville_sf1g <- filter(cville_sf1p, NAME == "Greene")
cville_sf1al <- filter(cville_sf1p, NAME == "Albemarle")
cville_sf1al <- rename(cville_sf1al, NAME1 = NAME, Julmin1 = Julmin, date1 = date)
cville_sf1c<- filter(cville_sf1p, NAME == "Charlottesville")
cville_sf1c <- rename(cville_sf1c, NAME2 = NAME, Julmin2 = Julmin, date2 = date)
cville_sf1f<- filter(cville_sf1p, NAME == "Fluvanna")
cville_sf1f <- rename(cville_sf1f, NAME3 = NAME, Julmin3 = Julmin, date3 = date)
cville_sf1l <- filter(cville_sf1p, NAME == "Louisa")
cville_sf1l <- rename(cville_sf1l, NAME4 = NAME, Julmin4 = Julmin, date4 = date)
cville_sf1n <- filter(cville_sf1p, NAME == "Nelson")
cville_sf1n <- rename(cville_sf1n, NAME5 = NAME, Julmin5 = Julmin, date5 = date)
cville_sf1x <- cbind(cville_sf1g, cville_sf1al, cville_sf1c, cville_sf1f, cville_sf1l, cville_sf1n)
cville_sf1x <- rename(cville_sf1x, Greene = Julmin, Albemarle = Julmin1, Charlottesville = Julmin2, Fluvanna = Julmin3, Louisa = Julmin4, Nelson = Julmin5)
cville_sf1x <- cville_sf1x[ , -which(names(cville_sf1x) %in% c("date1","date2", "date3", "date4", "date5", "NAME", "NAME1", "NAME2", "NAME3", "NAME4","NAME5"))]
cville_sf1x <- xts(x = cville_sf1x, order.by = cville_sf1x$date)
dygraph(cville_sf1x, main = "Minimum Temperature in July across Counties for all Years", ylab = "Temperature (F)") %>%
  dySeries("Greene", label = "Greene") %>%
  dySeries("Albemarle", label = "Albemarle") %>%
  dySeries("Charlottesville", label = "Charlottesville") %>%
  dySeries("Fluvanna", label = "Fluvanna") %>%
  dySeries("Louisa", label = "Louisa") %>%
  dySeries("Nelson", label = "Nelson") %>%
  dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = FALSE, highlightSeriesOpts = list(strokeWidth = 3)) %>% 
dyLegend(show = "always", hideOnMouseOut = FALSE, width = 400) %>% 
    dyRangeSelector(height = 20) %>%  dyOptions(colors = RColorBrewer::brewer.pal(6, "Set2"))
meta %>%
  filter(varname == "Julmin") %>% 
  select(about) %>% 
  as.list()

$about [1] “Monthly Divisional Temperature format (f7.2) Range of values -50.00 to 140.00 degrees Fahrenheit. Decimals retain a position in the 7-character field. Missing values in the latest year are indicated by -99.99. Missing values removed for visualization, resulting in no plots for 2021”

3.3.2 Average Yearly Temperatures

3.3.2.1 Average Yearly Maximum Temperature for Each County for all Years

#select only the annual temperature and year column
cville_sf1_yr <- select(cville_sf1, NAME, Year, Avg_Tempmax)

#rename the temperature column
cville_sf1_yr <- rename(cville_sf1_yr, ta = Avg_Tempmax)
#create a date column because stripes only works with format = date

cville_sf1_yr <- mutate(cville_sf1_yr, date = str_c(Year, "01-01", sep = "-") %>% ymd())
#Filter out each County. No need to do theme again it's already set 
cville_sf1_yrg <- filter(cville_sf1_yr, NAME == "Greene")
cville_sf1_yra <- filter(cville_sf1_yr, NAME == "Albemarle")
cville_sf1_yrc <- filter(cville_sf1_yr, NAME == "Charlottesville")
cville_sf1_yrf <- filter(cville_sf1_yr, NAME == "Fluvanna")
cville_sf1_yrl <- filter(cville_sf1_yr, NAME == "Louisa")
cville_sf1_yrn <- filter(cville_sf1_yr, NAME == "Nelson")
#Create the theme for the stripes image

theme_strip <- theme_minimal()+
                 theme(axis.text.y = element_blank(),
                       axis.line.y = element_blank(),
                       axis.title = element_blank(),
                       panel.grid.major = element_blank(),
                       legend.title = element_blank(),
                       axis.text.x = element_text(vjust = 3),
                       panel.grid.minor = element_blank(),
                        plot.title = element_text(size = 14, face = "bold")
                       )


col_strip <- brewer.pal(11, "RdBu")
3.3.2.1.1 Greene County Warming Stripes: Average Yearly Maximum Temperature
 ggplot(cville_sf1_yrg,
             aes(x = date, y = 1, fill = ta))+
        geom_tile()+
           scale_x_date(date_breaks = "6 years",
                     date_labels = "%Y",
                     expand = c(0, 0))+
           scale_y_continuous(expand = c(0, 0))+
           scale_fill_gradientn(colors = rev(col_strip))+
             guides(fill = guide_colorbar(barwidth = 1))+
            labs(title = "Greene County Average Yearly Maximum Temperature 1895-2020",
                caption = "Data: NOAA Surface Temperature Analysis")+
              theme_strip

3.3.2.1.2 Louisa County Warming Stripes: Average Yearly Maximum Temperature
 ggplot(cville_sf1_yrl,
             aes(x = date, y = 1, fill = ta))+
        geom_tile()+
           scale_x_date(date_breaks = "6 years",
                     date_labels = "%Y",
                     expand = c(0, 0))+
           scale_y_continuous(expand = c(0, 0))+
           scale_fill_gradientn(colors = rev(col_strip))+
             guides(fill = guide_colorbar(barwidth = 1))+
            labs(title = "Louisa County Average Yearly Maximum Temperature 1895-2020",
                caption = "Data: NOAA Surface Temperature Analysis")+
              theme_strip

3.3.2.1.3 Nelson County Warming Stripes: Average Yearly Maximum Temperature
 ggplot(cville_sf1_yrn,
             aes(x = date, y = 1, fill = ta))+
        geom_tile()+
           scale_x_date(date_breaks = "6 years",
                     date_labels = "%Y",
                     expand = c(0, 0))+
           scale_y_continuous(expand = c(0, 0))+
           scale_fill_gradientn(colors = rev(col_strip))+
             guides(fill = guide_colorbar(barwidth = 1))+
            labs(title = "Nelson County Average Yearly Maximum Temperature 1895-2020",
                caption = "Data: NOAA Surface Temperature Analysis")+
              theme_strip

3.3.2.1.4 Albemarle County Warming Stripes: Average Yearly Maximum Temperature
 ggplot(cville_sf1_yra,
             aes(x = date, y = 1, fill = ta))+
        geom_tile()+
           scale_x_date(date_breaks = "6 years",
                     date_labels = "%Y",
                     expand = c(0, 0))+
           scale_y_continuous(expand = c(0, 0))+
           scale_fill_gradientn(colors = rev(col_strip))+
             guides(fill = guide_colorbar(barwidth = 1))+
            labs(title = "Albemarle County Average Yearly Maximum Temperature 1895-2020",
                caption = "Data: NOAA Surface Temperature Analysis")+
              theme_strip

3.3.2.1.5 Charlottesville County Warming Stripes: Average Yearly Maximum Temperature
 ggplot(cville_sf1_yrc,
             aes(x = date, y = 1, fill = ta))+
        geom_tile()+
           scale_x_date(date_breaks = "6 years",
                     date_labels = "%Y",
                     expand = c(0, 0))+
           scale_y_continuous(expand = c(0, 0))+
           scale_fill_gradientn(colors = rev(col_strip))+
             guides(fill = guide_colorbar(barwidth = 1))+
            labs(title = "Charlottesville County Average Yearly Maximum Temperature 1895-2020",
                caption = "Data: NOAA Surface Temperature Analysis")+
              theme_strip

3.3.2.1.6 Fluvanna County Warming Stripes: Average Yearly Maximum Temperature
 ggplot(cville_sf1_yrf,
             aes(x = date, y = 1, fill = ta))+
        geom_tile()+
           scale_x_date(date_breaks = "6 years",
                     date_labels = "%Y",
                     expand = c(0, 0))+
           scale_y_continuous(expand = c(0, 0))+
           scale_fill_gradientn(colors = rev(col_strip))+
             guides(fill = guide_colorbar(barwidth = 1))+
            labs(title = "Fluvanna County Average Yearly Maximum Temperature 1895-2020",
                caption = "Data: NOAA Surface Temperature Analysis")+
              theme_strip

meta %>%
  filter(varname == "Avg_Tempmax") %>% 
  select(about) %>% 
  as.list()

$about [1] “Average yearly maximum temperature for each county. Created by suming the maximum temperature for each month, for each county, and taking the mean. NA’s for months in 2021 not currently available were removed and the mean calculated for the 6 months so far. Missing values removed for visualization, resulting in no plots for 2021”

3.3.2.2 Average Yearly Minimum Temperature across Counties for all Years

This is an interactive graph. Click on the graph to zoom, scroll through each year to see numeric temperature readings for all counties for each year.

dygraph(cville_sf1xm, main = "Average Yearly Minimum Temperature across Counties for all Years", ylab = "Temperature (F)") %>%
  dySeries("Greene", label = "Greene") %>%
  dySeries("Albemarle", label = "Albemarle") %>%
  dySeries("Charlottesville", label = "Charlottesville") %>%
  dySeries("Fluvanna", label = "Fluvanna") %>%
  dySeries("Louisa", label = "Louisa") %>%
  dySeries("Nelson", label = "Nelson") %>%
  dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = FALSE, highlightSeriesOpts = list(strokeWidth = 3)) %>% 
dyLegend(show = "always", hideOnMouseOut = FALSE, width = 400) %>% 
    dyRangeSelector(height = 20) %>%  dyOptions(colors = RColorBrewer::brewer.pal(6, "Set2"))
meta %>%
  filter(varname == "Avg_Tempmin") %>% 
  select(about) %>% 
  as.list()

$about [1] “Average yearly minimum temperature for each county. Created by suming the minimum temperature for each month, for each county, and taking the mean. NA’s for months in 2021 not currently available were removed and the mean calculated for the 6 months so far. Missing values removed for visualization, resulting in no plots for 2021”

3.3.3 Precipitation

3.3.3.1 Total Yearly Precipitation across Counties for all Years

This is an interactive graph. Click on the graph to zoom, scroll through each year to see numeric temperature readings for all counties for each year.

dygraph(cville_sf1xp, main = "Total Yearly Precipitation across Counties for all Years", ylab = "Precipitation") %>%
  dySeries("Greene", label = "Greene") %>%
  dySeries("Albemarle", label = "Albemarle") %>%
  dySeries("Charlottesville", label = "Charlottesville") %>%
  dySeries("Fluvanna", label = "Fluvanna") %>%
  dySeries("Louisa", label = "Louisa") %>%
  dySeries("Nelson", label = "Nelson") %>%
  dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = FALSE, highlightSeriesOpts = list(strokeWidth = 3)) %>% 
dyLegend(show = "always", hideOnMouseOut = FALSE, width = 400) %>% 
    dyRangeSelector(height = 20) %>%  dyOptions(colors = RColorBrewer::brewer.pal(6, "Set2"))
meta %>%
  filter(varname == "Tot_Temppcp") %>% 
  select(about) %>% 
  as.list()

$about [1] “Total yearly precipitation for each county. Created by suming the precipitation for each month, for each county. NA’s for months in 2021 not currently available were removed and the mean calculated for the 6 months so far. Missing values removed for visualization, resulting in no plots for 2021”

3.4 Eastern Shore Counties

noaa <- read_csv("noaa_eastern_county.csv")
easternfips <- c("001", "131")
meta <- read_sheet("https://docs.google.com/spreadsheets/d/1nqm3DuVXD1ObbVe_deacvT7uSLdBXfQJo3mkbqDwrVo/edit#gid=1573436636", sheet = "noaa")

3.5 Data Source

Source: NOAA’s Climate Divisional Database (nClimDiv), June 2021 release

3.5.1 The Data Used Here

The Climate Divisional Dataset from the National Center For Environmental Information began as the only long-term temporally and spatially complete dataset from which to generate historical climate analyses (1895-2013) for the contiguous United States (CONUS). It was originally developed for climate division, statewide, regional, national, and population-weighted monitoring of drought, temperature, precipitation, and heating/cooling degree day values.

There are 344 climate divisions in the CONUS. For each climate division, monthly station temperature and precipitation values are computed from the daily observations. The divisional values are weighted by area to compute statewide values and the statewide values are weighted by area to compute regional values. (Karl and Koss, 1984).

The data here is the county data from all the states in the contigous United States. While NOAA includes information on a variety of climate measures, we are focusing on the maximum, minimum temperature, and precipitation of the counties of interest.

To Learn More, See:

3.5.2 Variable Descriptions

glimpse(eastern_sf1)
## Rows: 252
## Columns: 50
## $ NAME        <chr> …
## $ Year        <dbl> …
## $ CNTY_FIPS   <chr> …
## $ X           <dbl> …
## $ Y           <dbl> …
## $ STATE_FIPS  <chr> …
## $ FIPS        <chr> …
## $ AREA        <dbl> …
## $ Janmin      <dbl> …
## $ Febmin      <dbl> …
## $ Marmin      <dbl> …
## $ Aprmin      <dbl> …
## $ Maymin      <dbl> …
## $ Junmin      <dbl> …
## $ Julmin      <dbl> …
## $ Augmin      <dbl> …
## $ Sepmin      <dbl> …
## $ Octmin      <dbl> …
## $ Novmin      <dbl> …
## $ Decmin      <dbl> …
## $ Avg_Tempmin <dbl> …
## $ Janmax      <dbl> …
## $ Febmax      <dbl> …
## $ Marmax      <dbl> …
## $ Aprmax      <dbl> …
## $ Maymax      <dbl> …
## $ Junmax      <dbl> …
## $ Julmax      <dbl> …
## $ Augmax      <dbl> …
## $ Sepmax      <dbl> …
## $ Octmax      <dbl> …
## $ Novmax      <dbl> …
## $ Decmax      <dbl> …
## $ Avg_Tempmax <dbl> …
## $ Janpcp      <dbl> …
## $ Febpcp      <dbl> …
## $ Marpcp      <dbl> …
## $ Aprpcp      <dbl> …
## $ Maypcp      <dbl> …
## $ Junpcp      <dbl> …
## $ Julpcp      <dbl> …
## $ Augpcp      <dbl> …
## $ Seppcp      <dbl> …
## $ Octpcp      <dbl> …
## $ Novpcp      <dbl> …
## $ Decpcp      <dbl> …
## $ Tot_Temppcp <dbl> …
## $ Avg_Temppcp <dbl> …
## $ Fipsyear    <dbl> …
## $ geometry    <MULTIPOLYGON [°]> …

Observations are county level estimates of…

  • Monthly maximum temperature for each county for years 1895-2021
    • Yearly average maximum temperature for each county for those years.
  • Monthly minimum temperature for each county for years 1895-2021
    • Yearly average minimum temperature for each county for those years.
  • Monthly precipitation for each county for years 1895-2021
    • Total yearly precipitation for each county for those years.

3.5.3 Summaries

5-number summaries of (non-missing) numeric variables (remove non-numeric observations)

noaa %>% select(-c(CNTY_FIPS, Fipsyear, Year)) %>% 
  select(where(~is.numeric(.x) && !is.na(.x))) %>% 
  as.data.frame() %>% 
  stargazer(., type = "text", title = "Summary Statistics", digits = 0,
            summary.stat = c("mean", "sd", "min", "median", "max"))
## 
## Summary Statistics
## ========================================
## Statistic   Mean St. Dev. Min Median Max
## ----------------------------------------
## Janmin       29     4     18    29   41 
## Febmin       30     4     17    30   37 
## Marmin       37     3     26    37   47 
## Aprmin       45     2     40   45.2  54 
## Maymin       55     3     48    55   63 
## Junmin       64     2     58    64   71 
## Julmin       69     2     64    69   74 
## Augmin       68     2     63    68   73 
## Sepmin       62     3     56    62   70 
## Octmin       52     3     44    52   60 
## Novmin       41     3     33    40   50 
## Decmin       33     4     22    33   46 
## Avg_Tempmin  49     1     45    49   52 
## Janmax       46     5     33    46   59 
## Febmax       47     5     34    48   59 
## Marmax       55     4     42    55   67 
## Aprmax       64     3     55    64   72 
## Maymax       73     3     67    73   81 
## Junmax       81     2     73    81   88 
## Julmax       86     2     81    86   91 
## Augmax       84     2     78    84   89 
## Sepmax       79     2     72    79   85 
## Octmax       69     3     64    69   77 
## Novmax       59     3     49    58   65 
## Decmax       49     4     38    50   62 
## Avg_Tempmax  66     1     62    66   70 
## Janpcp       3      1      1    3    10 
## Febpcp       3      1      0    3     8 
## Marpcp       4      2      0    4    10 
## Aprpcp       3      1      0    3     6 
## Maypcp       3      2      0    3     8 
## Junpcp       4      1      0    4     9 
## Julpcp       5      2     -10   4    13 
## Augpcp       4      3     -10   4    12 
## Seppcp       3      2     -10   3    13 
## Octpcp       3      2     -10   3    10 
## Novpcp       3      2     -10   2     9 
## Decpcp       3      2     -10   3     8 
## Tot_Temppcp  42     10    -40   42   60 
## Avg_Temppcp  4      1     -3    3     5 
## ----------------------------------------

3.6 Maps, Warming Stripes, and Timeplots

3.6.1 July Temperatures

3.6.1.1 Maximum Temperature in July across Counties for all Years

eastern_sf11a <- 
  ggplot(eastern_sf1) +
  geom_sf(aes(fill = Julmax), color = "black", alpha = .9, na.rm = TRUE) +
   geom_text_repel(data = eastern_sf1, aes(X, Y, label = NAME), size = 4, nudge_x = 1, nudge_y = 0, fontface = "bold", hjust = 0.9) +
  scale_fill_fermenter(palette = "YlOrRd", direction = 1,   type = "seq", n.breaks = 7) +
     theme_void() +
  guides(fill =
           guide_colourbar(title.position="top", title.hjust = 0.5,
                           barwidth = 1)
  )  + 
  labs(fill = "Temperature ", title = 'Year: {frame_time}',
       caption = "Maximum Temperature in July for Eastern Shore Counties") + 
 transition_time(as.integer(Year)) +
ease_aes('linear') 
animate(eastern_sf11a, fps = 1, detail = 1, nframes = 127)

meta %>%
  filter(varname == "Julmax") %>% 
  select(about) %>% 
  as.list()

$about [1] “Monthly Divisional Temperature format (f7.2) Range of values -50.00 to 140.00 degrees Fahrenheit. Decimals retain a position in the 7-character field. Missing values in the latest year are indicated by -99.99. Missing values removed for visualization, resulting in no plots for 2021”

3.6.1.2 Minimum Temperature in July across Counties for all Years

This is an interactive graph. Click on the graph to zoom, scroll through each year to see numeric temperature readings for all counties for each year.

eastern_sf1a <- mutate(eastern_sf1, date = str_c(Year, "07-16", sep = "-") %>% ymd())
eastern_sf1p <- select(eastern_sf1a, NAME, date, Julmin)
eastern_sf1p <- as.data.frame(eastern_sf1p)
eastern_sf1p <- select(eastern_sf1p, -starts_with("geometry"))
eastern_sf1g <- filter(eastern_sf1p, NAME == "Accomack")
eastern_sf1al <- filter(eastern_sf1p, NAME == "Northampton")
eastern_sf1al <- rename(eastern_sf1al, NAME1 = NAME, Julmin1 = Julmin, date1 = date)
eastern_sf1x <- cbind(eastern_sf1g, eastern_sf1al)
eastern_sf1x <- rename(eastern_sf1x, Accomack = Julmin, Northampton = Julmin1)
eastern_sf1x <- eastern_sf1x[ , -which(names(eastern_sf1x) %in% c("date1", "NAME", "NAME1"))]
eastern_sf1x <- xts(x = eastern_sf1x, order.by = eastern_sf1x$date)
dygraph(eastern_sf1x, main = "Minimum Temperature in July across Counties for all Years", ylab = "Temperature (F)") %>%
  dySeries("Accomack", label = "Accomack") %>%
  dySeries("Northampton", label = "Northampton") %>%
  dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = FALSE, highlightSeriesOpts = list(strokeWidth = 3)) %>% 
dyLegend(show = "always", hideOnMouseOut = FALSE, width = 400) %>% 
    dyRangeSelector(height = 20) %>%  dyOptions(colors = RColorBrewer::brewer.pal(3, "Set1"))

3.6.2 Average Yearly Temperatures

3.6.2.1 Average Yearly Maximum Temperature for Each County for all Years

#select only the annual temperature and year column
eastern_sf1_yr <- select(eastern_sf1, NAME, Year, Avg_Tempmax)

#rename the temperature column
eastern_sf1_yr <- rename(eastern_sf1_yr, ta = Avg_Tempmax)
#create a date column because stripes only works with format = date

eastern_sf1_yr <- mutate(eastern_sf1_yr, date = str_c(Year, "01-01", sep = "-") %>% ymd())
#Filter out each County. No need to do theme again it's already set 

eastern_sf1_yra <- filter(eastern_sf1_yr, NAME == "Accomack")
eastern_sf1_yrn <- filter(eastern_sf1_yr, NAME == "Northampton")
# Create a theme for the stripes image

theme_strip <- theme_minimal()+
                 theme(axis.text.y = element_blank(),
                       axis.line.y = element_blank(),
                       axis.title = element_blank(),
                       panel.grid.major = element_blank(),
                       legend.title = element_blank(),
                       axis.text.x = element_text(vjust = 3),
                       panel.grid.minor = element_blank(),
                        plot.title = element_text(size = 14, face = "bold")
                       )


col_strip <- brewer.pal(11, "RdBu")
3.6.2.1.1 Accomack County Warming Stripes: Average Yearly Maximum Temperature
 ggplot(eastern_sf1_yra,
             aes(x = date, y = 1, fill = ta))+
        geom_tile()+
           scale_x_date(date_breaks = "6 years",
                     date_labels = "%Y",
                     expand = c(0, 0))+
           scale_y_continuous(expand = c(0, 0))+
           scale_fill_gradientn(colors = rev(col_strip))+
             guides(fill = guide_colorbar(barwidth = 1))+
            labs(title = "Accomack County Average Yearly Maximum Temperature 1895-2020",
                caption = "Data: NOAA Surface Temperature Analysis")+
              theme_strip

3.6.2.1.2 Northampton County Warming Stripes: Average Yearly Maximum Temperature
 ggplot(eastern_sf1_yrn,
             aes(x = date, y = 1, fill = ta))+
        geom_tile()+
           scale_x_date(date_breaks = "6 years",
                     date_labels = "%Y",
                     expand = c(0, 0))+
           scale_y_continuous(expand = c(0, 0))+
           scale_fill_gradientn(colors = rev(col_strip))+
             guides(fill = guide_colorbar(barwidth = 1))+
            labs(title = "Northampton County Average Yearly Maximum Temperature 1895-2020",
                caption = "Data: NOAA Surface Temperature Analysis")+
              theme_strip

3.6.2.2 Average Yearly Minimum Temperature across Counties for all Years

This is an interactive graph. Click on the graph to zoom, scroll through each year to see numeric temperature readings for all counties for each year.

dygraph(eastern_sf1xm, main = "Average Yearly Minimum Temperature across Counties for all Years", ylab = "Temperature (F)") %>%
  dySeries("Accomack", label = "Accomack") %>%
  dySeries("Northampton", label = "Northampton") %>%
  dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = FALSE, highlightSeriesOpts = list(strokeWidth = 3)) %>% 
dyLegend(show = "always", hideOnMouseOut = FALSE, width = 400) %>% 
    dyRangeSelector(height = 20) %>%  dyOptions(colors = RColorBrewer::brewer.pal(3, "Set1"))
meta %>%
  filter(varname == "Avg_Tempmin") %>% 
  select(about) %>% 
  as.list()

$about [1] “Average yearly minimum temperature for each county. Created by suming the minimum temperature for each month, for each county, and taking the mean. NA’s for months in 2021 not currently available were removed and the mean calculated for the 6 months so far. Missing values removed for visualization, resulting in no plots for 2021”

3.6.3 Precipitation

3.6.3.1 Total Yearly Precipitation across Counties for all Years

This is an interactive graph. Click on the graph to zoom, scroll through each year to see numeric temperature readings for all counties for each year.

dygraph(eastern_sf1xp, main = "Total Yearly Precipitation across Counties for all Years", ylab = "Precipitation") %>%
  dySeries("Accomack", label = "Accomack") %>%
  dySeries("Northampton", label = "Northampton") %>%
  dyHighlight(highlightCircleSize = 3, 
              highlightSeriesBackgroundAlpha = 0.2,
              hideOnMouseOut = FALSE, highlightSeriesOpts = list(strokeWidth = 3)) %>% 
dyLegend(show = "always", hideOnMouseOut = FALSE, width = 400) %>% 
    dyRangeSelector(height = 20) %>%  dyOptions(colors = RColorBrewer::brewer.pal(3, "Set1"))